<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			#msg{margin:50px;}
			.btnstyle{margin:0px 0px 0px 50px;}
		</style>
	</head>
	<body>
		<div id="msg">0</div>
	<div class="btnstyle">	
		<button id="btnStart"onclick="start();">开始计时</button>
		<button id="btnStop"onclick="stop();">结束计时</button>
		</div>
	</body>
	<script>
		var count=0;
		//点击开始，计时定时刷新+n,按钮名称：改成暂停计时
		function start(){
			count=count +1;
			var msg=document.getElementById("msg");
			msg.innerText=count;
			setInterval(start,10);
			var btnStart=document.getElementById("btnStart");
			btnStart.innerText='暂停计时';
		}
		//点击结束，清除定时器，总值等于0，按钮名称改为开始计时
		function stop(){
			count=0;
			clearInterval(start);//清除定时器
			var btnStop=document.getElementById("btnStop");
			btnStart.innerText='开始计时';
		}
		
	</script>
</html>
